package com.example.permanentroom;

import Service.UserService;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    private EditText username_view;
    private EditText password_view;
    private Switch Switch_view;
    public static String userid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }

    public void Login(View view) {
        UserService userService=new UserService();
        String nickname = (username_view=(EditText) findViewById(R.id.username)).getText().toString();
        String password = (password_view=(EditText) findViewById(R.id.password)).getText().toString();
        String flag=userService.login(nickname,password);
        if(flag.equals("false")){
            Toast.makeText(this, "登陆失败", Toast.LENGTH_LONG).show();

        }
        else{userid=flag;
            Toast.makeText(this, "登录成功", Toast.LENGTH_LONG).show();
            Intent intent=new Intent(this,shouye.class);
            startActivity(intent); }
    }
    public void goRegister(View view) {
        Intent intent=new Intent(this,register.class);
       startActivity(intent);
    }




}